<template>
	<view class="page">

		<view class="example-body">
			<combox-search v-if="allList.length > 0" label="选择病例" labelWidth="100px" emptyTips="无匹配选项" :isJSON="true"
				:keyName="keyName" :candidates="allList" v-model="inputVlue" placeholder="选择症状" @getValue="getValue($event,'json')">
			</combox-search>
		</view>

		<view class="mt-40 mlr-36" style="background: #f8f8f8;">
			<u-field type="textarea" class="w100" v-model="message" :auto-height="false" :clearable="false"
				label-width="0" placeholder="请输入病人情况"></u-field>
		</view>

		<view class="fixed-bottom pb-80">
			<u-button type="primary" :disabled="!message" @click="submit">提交</u-button>
		</view>
	</view>
</template>

<script>
	import comboxSearch from "@/components/cuihai-combox/cuihai-combox.vue"
	export default {
		components: {
			comboxSearch,
		},
		onLoad(option) {

			this.id = option.id
			console.log(this.id);
		},
		mounted() {
			this.getList()
		},
		data() {
			return {
				// candidates: [{"id":1,"name":"肺气肿","sort":1,"createtime":1653287233},{"id":2,"name":"支气管哮喘","sort":2,"createtime":1653287254},{"id":3,"name":"肺炎","sort":3,"createtime":1653287294},{"id":4,"name":"肺结核","sort":4,"createtime":1653287304}],
				keyName: 'name',
				message: '',
				inputVlue: '',
				candidates2: ['北京', '南京', '东京', '西京'],
				initValue: [1, 2],
				allList: [],
				index: null,
				city: '北京',
				city2: '北京',
				city3: '',
				casesName: '',
				selectBgColor: '#FCF681',
				selectColor: 'red',
				submitbtn: true
			}
		},
		methods: {

			submit() {
				console.log(this.submitbtn)
				if (this.submitbtn == true) {
					console.log('1111');
					this.submitbtn = false
					this.$http('/addons/ddrive/order/binglei', {
						order_id: this.id,
						remark: this.message,
						binglei: this.caseType
					}, "POST").then(data => {
						uni.showToast({
							title: '提交成功'
						})
						setTimeout(() => {
							uni.navigateBack({})
						}, 1000)
					}).catch(data => {
						this.submitbtn = true
					})
				}
			},
			getList() {
				this.$http('/addons/ddrive/order/binglei', {
					order_id: this.id,
				}).then(res => {

					// this.allList = JSON.stringify(res)
					this.allList = res.list
					this.message = res.remark
					this.binglei = res.binglei
					console.log(this.allList);
					this.casesNameList = this.allList.filter(value => value.id == this.binglei)
					this.casesName = this.casesNameList[0].name
					this.inputVlue =  this.casesName
					console.log(this.casesName);
				
				})
			},
			getValue(e, type) {
				switch (type) {
					case 'json':
						this.index = e;
						break;
					case 'common':
						this.city = e;
						break;
					case 'common2':
						this.city2 = e;
						break;
					case 'common3':
						this.city3 = e;
						break;
					default:
						break;
				}
				console.log(e);
				this.caseType = e + 1
			},
			go() {
				uni.navigateTo({
					url: "../select/select"
				})
			}
		}
	}
</script>

<style>
	/* 头条小程序组件内不能引入字体 */
	/* #ifdef MP-TOUTIAO */
	@font-face {
		font-family: uniicons;
		font-weight: normal;
		font-style: normal;
		src: url('~@/static/img/uni.ttf') format('truetype');
	}

	/* #endif */

	/* #ifndef APP-NVUE */
	page {
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		background-color: #efeff4;
		min-height: 100%;
		height: auto;
	}

	view {
		font-size: 14px;
		line-height: inherit;
	}

	.example {
		padding: 0 15px 15px;
	}

	.example-info {
		padding: 15px;
		color: #3b4144;
		background: #ffffff;
	}

	.example-body {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		flex-wrap: wrap;
		justify-content: center;
		padding: 0;
		font-size: 14px;
		background-color: #ffffff;
		/* overflow: hidden; */
	}

	/* #endif */
	.example {
		padding: 0 15px;
	}

	.example-info {
		/* #ifndef APP-NVUE */
		display: block;
		/* #endif */
		padding: 15px;
		color: #3b4144;
		background-color: #ffffff;
		font-size: 14px;
		line-height: 20px;
	}

	.example-info-text {
		font-size: 14px;
		line-height: 20px;
		color: #3b4144;
	}


	.example-body {
		flex-direction: column;
		padding: 15px;
		background-color: #ffffff;
	}

	.word-btn-white {
		font-size: 18px;
		color: #FFFFFF;
	}

	.word-btn {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: center;
		justify-content: center;
		border-radius: 6px;
		height: 48px;
		margin: 15px;
		background-color: #007AFF;
	}

	.word-btn--hover {
		background-color: #4ca2ff;
	}


	.example-body {
		padding: 0px 12px;
		background-color: #FFFFFF;
	}

	.result-box {
		text-align: center;
		padding: 20px 0px;
		font-size: 16px;
	}
</style>
